package start;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class MyInterceptor implements HandlerInterceptor {
    public MyInterceptor() {
        System.out.println("Create MyInterceptor..");
    }

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                             Object object) throws Exception {
        System.out.println("MyInterceptor. preHandle("+httpServletRequest+","+httpServletResponse+")");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                           Object object, ModelAndView modelAndView) throws Exception {
        System.out.println("MyInterceptor. postHandle("+httpServletRequest+","+httpServletResponse+","+object+","+modelAndView+")");
    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                                Object object, Exception exception) throws Exception {
        System.out.println("MyInterceptor. afterCompletion("+httpServletRequest+","+httpServletResponse+")");        
    }
}
